home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume13 / conf / part04 < prev    next >
Encoding:
Internet Message Format  |  1988-03-13  |  10.0 KB

  1. Subject:  v13i101:  Multi-user conferencing system, Part04/05
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Keith Gabryelski <ag@crash.cts.com>
  7. Posting-number: Volume 13, Issue 101
  8. Archive-name: conf/part04
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create the files:
  15. #    confsig.c
  16. #    confstr.c
  17. #    extern.h
  18. #    structs.h
  19. export PATH; PATH=/bin:$PATH
  20. if test -f 'confsig.c'
  21. then
  22.     echo shar: will not over-write existing file "'confsig.c'"
  23. else
  24. cat << \SHAR_EOF > 'confsig.c'
  25.  
  26. /*
  27.  *    conf - An interactive multi-user chat program.
  28.  *
  29.  *    conf Copyright (c) 1986, 1987 by Keith Gabryelski
  30.  *
  31.  *    Conf is quasi-public domain software; it may be used and copied
  32.  *    freely and may be modified to suit the indivuals needs as long
  33.  *    as:
  34.  *
  35.  *    [1] It is not sold.
  36.  *    [2] It is not made part of any licensed product.
  37.  *    [3] This header and others like it are not modified or removed.
  38.  *    [4] You allow others to use and copy without charge.
  39.  *    
  40.  *    without expressed written permission from the original
  41.  *    author (Keith Gabryelski).
  42.  *
  43.  *
  44.  */
  45.  
  46. #include "conf.h"
  47.  
  48. int nsig = 16;
  49.  
  50. char *sig_list[] =
  51. {
  52.     "Unkown Signal: 0",
  53.     "Hangup",
  54.     "Interrupt",
  55.     "Quit",
  56.     "Illegal Instruction",
  57.     "Trace Trap", 
  58.     "IOT Instruction",
  59.     "EMT Instruction",
  60.     "Floating Point Exception",
  61.     "Kill",
  62.     "Bus Error",
  63.     "Segmentation Violation",
  64.     "Bad Argument To System Call",
  65.     "Write On A Pipe With No One To Read It",
  66.     "Alarm Clock",
  67.     "Software Termination Signal From Kill",
  68. };
  69.  
  70. fatal(sig)
  71. int sig;
  72. {
  73.     int c, p;
  74.  
  75.     (void)printf("\nFatal Signal %d (%s).\n", sig, putsig(sig));
  76.     make_nice(FALSE);
  77.     if (askdump || (sig == SIGQUIT))
  78.     {
  79.     p = TRUE;
  80.     (void)fputs("dump core? [y] ", stdout);
  81.     while(((c = getchar()) != '\n') && (c != EOF))
  82.     {
  83.         switch(c)
  84.         {
  85.         case 'y':
  86.         case 'Y':
  87.             p = TRUE;
  88.             break;
  89.  
  90.         case 'n':
  91.         case 'N':
  92.             p = FALSE;
  93.             break;
  94.         }
  95.     }
  96.  
  97.     if (p)
  98.     {
  99.         p = kill(cuser.cu_procid, sig);
  100.         if (p <0)
  101.         (void)fprintf(stderr, "%s: Couldn't kill proccess %d (%s)\n",
  102.             progname, cuser.cu_procid, puterr(errno));
  103.     }
  104.     }
  105.     (void) exit(-1);
  106. }
  107.  
  108. char *
  109. putsig(sig)
  110. int sig;
  111. {
  112.     static char qwerty[42];
  113.  
  114.     (void)sprintf(qwerty, "Unknown Signal: %d", sig);
  115.  
  116.     return ((unsigned)sig >= nsig) ? qwerty : sig_list[sig];
  117. }
  118. SHAR_EOF
  119. fi # end of overwriting check
  120. if test -f 'confstr.c'
  121. then
  122.     echo shar: will not over-write existing file "'confstr.c'"
  123. else
  124. cat << \SHAR_EOF > 'confstr.c'
  125. /*
  126.  *    conf - An interactive multi-user chat program.
  127.  *
  128.  *    conf Copyright (c) 1986, 1987 by Keith Gabryelski
  129.  *
  130.  *    Conf is quasi-public domain software; it may be used and copied
  131.  *    freely and may be modified to suit the indivuals needs as long
  132.  *    as:
  133.  *
  134.  *    [1] It is not sold.
  135.  *    [2] It is not made part of any licensed product.
  136.  *    [3] This header and others like it are not modified or removed.
  137.  *    [4] You allow others to use and copy without charge.
  138.  *    
  139.  *    without expressed written permission from the original
  140.  *    author (Keith Gabryelski).
  141.  *
  142.  */
  143.  
  144. #include "conf.h"
  145.  
  146. unsigned int wordlen;
  147.  
  148. char *
  149. parsestr(string, length, flags)
  150. char *string;
  151. int length, flags;
  152. {
  153.     static char *retbuf;
  154.     static int buflen = 0;
  155.     static char *prevs;
  156.     static int prevl;
  157.     char *p;
  158.  
  159.     if (buflen == 0)
  160.     retbuf = mymalloc((unsigned)(buflen = PAGESIZ));
  161.  
  162.     p = retbuf;
  163.  
  164.     if (!length)
  165.     {
  166.     string = prevs;
  167.     length = prevl;
  168.     }
  169.  
  170.     while (length && isspace(*string))
  171.     {
  172.         ++string;
  173.     --length;
  174.     }
  175.  
  176.     prevs = string;
  177.     prevl = length;
  178.  
  179.     if (!length)
  180.     {
  181.     wordlen = linelen = 0;
  182.     return NULL;
  183.     }
  184.  
  185.     while (length && ((flags&THEREST) || (!isspace(*string)&&(*string != ',')&&(*string != '='))))
  186.     {
  187.     if (*string == '"')
  188.     {
  189.         ++string;  --length;
  190.  
  191.         while (length && (*string != '"'))
  192.         {
  193.         if (*string == '\\')
  194.         {
  195.             ++string; --length;
  196.  
  197.             if (length && isdigit(*string))
  198.             {
  199.             int x, c;
  200.  
  201.             x = (*string++ - '0');  --length;
  202.  
  203.             if (length && isdigit(*string))
  204.             {
  205.                 x = (x * 10) + (*string++ - '0');  --length;
  206.  
  207.                 if (length && isdigit(*string))
  208.                 {
  209.                 c = (x * 10) + (*string - '0');
  210.                 if (c < 256)
  211.                 {
  212.                     x = c;
  213.                     ++string;  --length;
  214.                 }
  215.                 }
  216.             }
  217.  
  218.             *p++ = x;
  219.             }
  220.             else
  221.             if (length)
  222.             {
  223.                 *p++ = *string++;  --length;
  224.             }
  225.         }
  226.         else
  227.         {
  228.             *p++ = *string++; --length;
  229.         }
  230.         }
  231.     }
  232.     else
  233.     {
  234.         if (*string == '\\')
  235.         {
  236.         ++string; --length;
  237.  
  238.         if (length && isdigit(*string))
  239.         {
  240.             int x, c;
  241.  
  242.             x = (*string++ - '0');  --length;
  243.  
  244.             if (length && isdigit(*string))
  245.             {
  246.             x = (x * 10) + (*string++ - '0');  --length;
  247.  
  248.             if (length && isdigit(*string))
  249.             {
  250.                 c = (x * 10) + (*string - '0');
  251.                 if (c < 256)
  252.                 {
  253.                 x = c;
  254.                 ++string;  --length;
  255.                 }
  256.             }
  257.             }
  258.  
  259.             *p++ = x;
  260.         }
  261.         else
  262.             if (length)
  263.             {
  264.             *p++ = *string++;  --length;
  265.             }
  266.         }
  267.         else
  268.         {
  269.         *p++ = *string++; --length;
  270.         }
  271.     }
  272.     }
  273.  
  274.     *p = '\0';
  275.  
  276.     while (length && isspace(*string))
  277.     {
  278.         ++string;  --length;
  279.     }
  280.  
  281.     if (length && ((*string == ',') || (*string == '=')))
  282.     {
  283.     ++string;  --length;
  284.     } 
  285.  
  286.     prevs = string;
  287.     prevl = length;
  288.  
  289.     linelen = length;
  290.     wordlen = p - retbuf;
  291.  
  292.     return wordlen ? retbuf : NULL;
  293. }
  294.  
  295. cpystr(to, from, length)
  296. register char *to, *from;
  297. register unsigned int length;
  298. {
  299.    while(length--) *to++ = *from++;
  300. }
  301.  
  302. zbuf(ptr, length)
  303. register char *ptr;
  304. register unsigned int length;
  305. {
  306.     while(length--) *ptr = '\0';
  307. }
  308.  
  309. cmpdat(dat1, dat2, length)
  310. register char *dat1, *dat2;
  311. register int length;
  312. {
  313.     while (length--)
  314.     if (*dat1++ != *dat2++)
  315.         return FALSE;
  316.  
  317.     return TRUE;
  318. }
  319.  
  320. char *
  321. puterr(error)
  322. int error;
  323. {
  324.     static char qwerty[42];
  325.  
  326.     (void)sprintf(qwerty, "Unknown error %d", error);
  327.  
  328.     return ((unsigned)error >= sys_nerr) ? qwerty : sys_errlist[error];
  329. }
  330. SHAR_EOF
  331. fi # end of overwriting check
  332. if test -f 'extern.h'
  333. then
  334.     echo shar: will not over-write existing file "'extern.h'"
  335. else
  336. cat << \SHAR_EOF > 'extern.h'
  337. /*
  338.  *    conf - An interactive multi-user chat program.
  339.  *
  340.  *    conf Copyright (c) 1986, 1987 by Keith Gabryelski
  341.  *
  342.  *    Conf is quasi-public domain software; it may be used and copied
  343.  *    freely and may be modified to suit the indivuals needs as long
  344.  *    as:
  345.  *
  346.  *    [1] It is not sold.
  347.  *    [2] It is not made part of any licensed product.
  348.  *    [3] This header and others like it are not modified or removed.
  349.  *    [4] You allow others to use and copy without charge.
  350.  *    
  351.  *    without expressed written permission from the original
  352.  *    author (Keith Gabryelski).
  353.  *
  354.  */
  355.  
  356. extern errno;
  357.  
  358. extern struct passwd *getpwuid();
  359.  
  360. extern FILE *fopen(), *popen();
  361. extern char *getlogin(), *malloc(), *realloc(), *strchr(), *strrchr();
  362. extern char *ttyname(), *getenv(), *strcpy(), *strncpy(), *strcat();
  363.  
  364. #ifdef    USE_TERMCAP
  365. extern char *tgetstr();
  366. extern void tputs();
  367. #endif    USE_TERMCAP
  368.  
  369. extern char *sys_errlist[];
  370. extern int sys_nerr;
  371. extern long lseek();
  372. extern void free(), longjmp();
  373. extern unsigned alarm(), sleep();
  374.  
  375. extern char *progname;
  376. extern int log_rfd, log_wfd, usr_fd;
  377. extern long ourplace;
  378. extern FILE *rec_fp;
  379. extern int confing, columns, lines;
  380. extern char ichar, qchar;
  381.  
  382. extern char pubkey[], curkey[], pubblock[], curblock[], pubpass[], curpass[];
  383. extern char *wrdata, replytty[], replyname[];
  384. extern unsigned wdlen;
  385.  
  386. extern struct cusrfil cuser, tuser;
  387. extern struct clogfil clog, tlog;
  388.  
  389. extern int banner, seeme, informe, warncrypt, autowho, lineinput, beep;
  390. extern int expand8bit, expandctrl, askdump;
  391. extern unsigned linelen, wordlen;
  392.  
  393. extern int nice_exit(), makepass(), enccpy(), write_log();
  394. extern int version(), do_to(), set_pass(), messptr(), colprnt(), fatal();
  395. extern int getopts(), getrc(), setopts(), dispchar(), do_ring();
  396. extern char *logname, *homedir;
  397. extern char *pager, *shell, *normform, *lineform, *shoutform, *sendform;
  398. extern char *informform, *recfile;
  399.  
  400. char *cls;
  401.  
  402. #ifdef    SYSV
  403. extern struct termio term, saveterm;
  404. #endif    SYSV
  405.  
  406. #ifdef    BSD
  407. extern struct sgttyb ktty;
  408. extern int ttyflags;
  409. #endif    BSD
  410.  
  411. extern char *getline(), *mymalloc(), *myrealloc(), *puterr();
  412. extern char *getword(), *parsestr(), *putsig();
  413. SHAR_EOF
  414. fi # end of overwriting check
  415. if test -f 'structs.h'
  416. then
  417.     echo shar: will not over-write existing file "'structs.h'"
  418. else
  419. cat << \SHAR_EOF > 'structs.h'
  420. /*
  421.  *    conf - An interactive multi-user chat program.
  422.  *
  423.  *    conf Copyright (c) 1986, 1987 by Keith Gabryelski
  424.  *
  425.  *    Conf is quasi-public domain software; it may be used and copied
  426.  *    freely and may be modified to suit the indivuals needs as long
  427.  *    as:
  428.  *
  429.  *    [1] It is not sold.
  430.  *    [2] It is not made part of any licensed product.
  431.  *    [3] This header and others like it are not modified or removed.
  432.  *    [4] You allow others to use and copy without charge.
  433.  *    
  434.  *    without expressed written permission from the original
  435.  *    author (Keith Gabryelski).
  436.  *
  437.  */
  438.  
  439. /*
  440.  * logfile (CONFLOG) structer
  441.  *
  442.  */
  443.  
  444. struct clogfil
  445. {
  446.     int type;
  447.     int f_line;
  448.     unsigned int f_usrlen;
  449.     unsigned int f_ttylen;
  450.     unsigned int t_utlen;
  451.     unsigned int messlen;
  452.     char password[8];
  453. };
  454.  
  455. /*
  456.  * message type
  457.  *
  458.  */
  459.  
  460. #define    NORMAL        0
  461. #define    SEND        1
  462. #define    SHOUT        2
  463. #define    INFORM        3
  464.  
  465. /*
  466.  * userfile (CONFUSERS) struct
  467.  *
  468.  */
  469.  
  470. struct cusrfil
  471. {
  472.     int cu_flags;
  473.     char cu_cname[MAXNAMELEN];
  474.     char cu_tty[MAXTTYLEN];
  475.     int cu_line;
  476.     short cu_procid;
  477. };
  478.  
  479. /*
  480.  * cu_flags
  481.  *
  482.  */
  483.  
  484. #define    USER_OFF    0
  485. #define    USER_ON        1
  486. #define    USER_RECORD    2
  487.  
  488. /*
  489.  * Structure of valid options
  490.  *
  491.  */
  492.  
  493. struct varopts
  494.     {
  495.     char *name;
  496.     int type;
  497.     int *var;
  498.     int extra;
  499.     int (*var_func)();
  500.     };
  501.  
  502. /*
  503.  * Some flags to go with varopt struct
  504.  *
  505.  */
  506.  
  507. #define    BOOLEAN        0
  508. #define    NUMBER        1
  509. #define    STRING        2
  510. #define    VARMASK        3
  511.  
  512. #define    DISPLAY        0
  513. #define    NODISPLAY    4
  514. #define    DISPLAYMASK    4
  515.  
  516. #define    POINTER        1
  517. #define    ROUTINE        2
  518.  
  519. /*
  520.  * Return values from setops
  521.  *
  522.  */
  523.  
  524. #define    NOOPT        0
  525. #define    FOUNDOPT    1
  526. #define    AMBIGUOUS    2
  527.  
  528. /*
  529.  * for the who routine
  530.  *
  531.  */
  532.  
  533. struct whostr
  534.     {
  535.     char name[MAXNAMELEN+1];
  536.     char tty[MAXTTYLEN+1];
  537.     int line;
  538.     int flags;
  539.     };
  540. SHAR_EOF
  541. fi # end of overwriting check
  542. #    End of shell archive
  543. exit 0
  544.  
  545.